#include <iostream>
using namespace std;

const int N = 100010;
int a[N], b[N];
int n, m;

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i)
        scanf("%d", a + i);
    for (int i = 0; i < m; ++i)
        scanf("%d", b + i);
    int i, j;
    for (i = 0, j = 0; i < n && j < m; ++j)
    {
        while (a[i] != b[j] && j < m)
            j++;
        while (a[i] == b[j] && i < n && j < m)
            i++, j++;
    }
    if (i == n)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}